﻿/*
Copyright (c) 2012 Maksim Gordeev

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

*/

/*
 * Сделано в SharpDevelop.
 * Пользователь: maxxadm
 * Дата: 05.06.2012
 * Время: 19:44
 * 
 * Для изменения этого шаблона используйте Сервис | Настройка | Кодирование | Правка стандартных заголовков.
 */
using System;
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;

namespace jellybird.core
{
	/*
	 * https://dev.twitter.com/docs/platform-objects/entities
	 */
	
	/// <summary>
	/// Entities provide metadata and additional contextual information about
	/// content posted on Twitter. Entities are never divorced from the content
	///	they describe. After May 14th, 2012 Tweet Entities will be returned
	///	wherever Tweets are found in the API. Entities are instrumental in resolving URLs.
	/// Consumers of Entities should tolerate the addition of new fields and variance
	///	in ordering of fields with ease. Not all fields appear in all contexts.
	///	It is generally safe to consider a nulled field, an empty set, and
	///	the absence of a field as the same thing.
	/// </summary>
	[TypeConverter(typeof(ExpandableObjectConverter))]
	[JsonObject(MemberSerialization.OptIn)]
	public class TwEntities
	{
		public TwEntities()
		{
		}
		
		List<TwEntityHashtag> hashtags;
//		TwEntityHashtag[] hashtags;
		
		/// <summary>
		/// Represents hashtags which have been parsed out of the Tweet text.
		/// </summary>
		[JsonProperty("hashtags")]
		public List<TwEntityHashtag> Hashtags {
//		public TwEntityHashtag[] Hashtags {
			get { return hashtags; }
			set { hashtags = value; }
		}
		
		List<TwEntityMedia> media;
		
		/// <summary>
		/// Represents media elements uploaded with the Tweet.
		/// </summary>
		[JsonProperty("media")]
		public List<TwEntityMedia> Media {
			get { return media; }
			set { media = value; }
		}
		
		List<TwEntityUrl> urls;
//		TwEntityUrl[] urls;
		
		/// <summary>
		/// Represents URLs included in the text of the Tweet.
		/// </summary>
		[JsonProperty("urls")]
		public List<TwEntityUrl> Urls {
//		public TwEntityUrl[] Urls {
			get { return urls; }
			set { urls = value; }
		}
		
		List<TwEntityUserMention> userMentions;
		
		/// <summary>
		/// Represents other Twitter users mentioned in the text of the Tweet.
		/// </summary>
		[JsonProperty("user_mentions")]
		public List<TwEntityUserMention> UserMentions {
			get { return userMentions; }
			set { userMentions = value; }
		}
	}
	
	public class TwEntityHashtag
	{
		public TwEntityHashtag()
		{	
		}
		
		List<int> indices;
//		int[] indices;
		
		/// <summary>
		/// An array of integers indicating the offsets within the Tweet
		///	text where the hashtag begins and ends. The first integer represents
		///	the location of the # character in the Tweet text string. The second
		///	integer represents the location of the first character after the
		///	hashtag. Therefore the difference between the two numbers will be
		///	the length of the hashtag name plus one (for the '#' character).
		/// </summary>
		[JsonProperty("indices")]
		public List<int> Indices {
//		public int[] Indices {
			get { return indices; }
			set { indices = value; }
		}
		
		string text;
		
		/// <summary>
		/// Name of the hashtag, minus the leading '#' character.
		/// </summary>
		[JsonProperty("text")]
		public string Text {
			get { return text; }
			set { text = value; }
		}
	}
	
	public class TwEntitySize
	{
		public TwEntitySize()
		{	
		}
		
		int height;
		
		/// <summary>
		/// Height in pixels of this size.
		/// </summary>
		[JsonProperty("h")]
		public int Height {
			get { return height; }
			set { height = value; }
		}
		
		string resizeType;
		
		/// <summary>
		/// Resizing method used to obtain this size. A value of fit means that
		/// the media was resized to fit one dimension, keeping its native aspect
		///	ratio. A value of crop means that the media was cropped in order to fit
		///	a specific resolution.
		/// </summary>
		[JsonProperty("resize")]
		public string ResizeType {
			get { return resizeType; }
			set { resizeType = value; }
		}
		
		int width;
		
		/// <summary>
		/// Width in pixels of this size.
		/// </summary>
		[JsonProperty("w")]
		public int Width {
			get { return width; }
			set { width = value; }
		}
	}
	
	public class TwEntitySizes
	{
		public TwEntitySizes()
		{	
		}
		
		TwEntitySize thumb;
		
		/// <summary>
		/// Information for a thumbnail-sized version of the media.
		/// </summary>
		[JsonProperty("thumb")]
		public TwEntitySize Thumb {
			get { return thumb; }
			set { thumb = value; }
		}
		
		TwEntitySize large;
		
		/// <summary>
		/// Information for a large-sized version of the media.
		/// </summary>
		[JsonProperty("large")]
		public TwEntitySize Large {
			get { return large; }
			set { large = value; }
		}
		
		TwEntitySize medium;
		
		/// <summary>
		/// Information for a medium-sized version of the media.
		/// </summary>
		[JsonProperty("medium")]
		public TwEntitySize Medium {
			get { return medium; }
			set { medium = value; }
		}
		
		TwEntitySize small;
		
		/// <summary>
		/// Information for a small-sized version of the media.
		/// </summary>
		[JsonProperty("small")]
		public TwEntitySize Small {
			get { return small; }
			set { small = value; }
		}
	}
	
	public class TwEntityMedia
	{
		public TwEntityMedia()
		{	
		}
		
		string displayUrl;
		
		/// <summary>
		/// URL of the media to display to clients.
		/// </summary>
		/// <example>
		/// "display_url":"pic.twitter.com\/rJC5Pxsu"
		/// </example>
		[JsonProperty("display_url")]
		public string DisplayUrl {
			get { return displayUrl; }
			set { displayUrl = value; }
		}
		
		string expandedUrl;
		
		/// <summary>
		/// An expanded version of display_url. Links to the media display page.
		/// </summary>
		/// <example>
		/// "expanded_url": "http:\/\/twitter.com\/yunorno\/status\/114080493036773378\/photo\/1"
		/// </example>
		[JsonProperty("expanded_url")]
		public string ExpandedUrl {
			get { return expandedUrl; }
			set { expandedUrl = value; }
		}
		
		long id;
		
		/// <summary>
		/// ID of the media expressed as a 64-bit integer.
		/// </summary>
		[JsonProperty("id")]
		public long Id {
			get { return id; }
			set { id = value; }
		}
		
		string idString;
		
		/// <summary>
		/// ID of the media expressed as a string.
		/// </summary>
		[JsonProperty("id_str")]
		public string IdString {
			get { return idString; }
			set { idString = value; }
		}
		
		List<int> indices;
		
		/// <summary>
		/// An array of integers indicating the offsets within the Tweet text
		///	where the URL begins and ends. The first integer represents
		///	the location of the first character of the URL in the Tweet text.
		///	The second integer represents the location of the first non-URL
		/// character occurring after the URL (or the end of the string if
		///	the URL is the last part of the Tweet text).
		/// </summary>
		[JsonProperty("indices")]
		public List<int> Indices {
			get { return indices; }
			set { indices = value; }
		}
		
		string mediaUrl;
		
		/// <summary>
		/// An http:// URL pointing directly to the uploaded media file.
		/// </summary>
		/// <example>
		/// "media_url":"http:\/\/p.twimg.com\/AZVLmp-CIAAbkyy.jpg"
		/// </example>
		[JsonProperty("media_url")]
		public string MediaUrl {
			get { return mediaUrl; }
			set { mediaUrl = value; }
		}
		
		string mediaUrlHttps;
		
		/// <summary>
		/// An https:// URL pointing directly to the uploaded media file,
		///	for embedding on https pages.
		/// </summary>
		/// <example>
		/// "media_url_https":"https:\/\/p.twimg.com\/AZVLmp-CIAAbkyy.jpg"
		/// </example>
		[JsonProperty("media_url_https")]
		public string MediaUrlHttps {
			get { return mediaUrlHttps; }
			set { mediaUrlHttps = value; }
		}
		
		TwEntitySizes sizes;
		
		/// <summary>
		/// An object showing available sizes for the media file.
		/// </summary>
		/// <example>
		/// "sizes":{"thumb":{"h":150, "resize":"crop", "w":150},
		///	"large":{"h":238, "resize":"fit", "w":226},
		///	"medium":{"h":238, "resize":"fit", "w":226},
		///	"small":{"h":238, "resize":"fit", "w":226}}
		/// </example>
		[JsonProperty("sizes")]
		public TwEntitySizes Sizes {
			get { return sizes; }
			set { sizes = value; }
		}
		
		string mediaType;
		
		/// <summary>
		/// Type of uploaded media.
		/// </summary>
		/// <example>
		/// "type":"photo"
		/// </example>
		[JsonProperty("type")]
		public string MediaType {
			get { return mediaType; }
			set { mediaType = value; }
		}
		
		string url;
		
		/// <summary>
		/// Wrapped URL for the media link. This corresponds with the URL embedded
		///	directly into the raw Tweet text, and the values for the indices parameter
		/// </summary>
		/// <example>
		/// "url":"http:\/\/t.co\/rJC5Pxsu"
		/// </example>
		[JsonProperty("url")]
		public string RowUrl {
			get { return url; }
			set { url = value; }
		}
	}
	
	public class TwEntityUrl
	{
		public TwEntityUrl()
		{	
		}
		
		string dislayUrl;
		
		/// <summary>
		/// Version of the URL to display to clients.
		/// </summary>
		[JsonProperty("display_url")]
		public string DislayUrl {
			get { return dislayUrl; }
			set { dislayUrl = value; }
		}
		
		string expandedUrl;
		
		/// <summary>
		/// Expanded version of display_url.
		/// </summary>
		[JsonProperty("expanded_url")]
		public string ExpandedUrl {
			get { return expandedUrl; }
			set { expandedUrl = value; }
		}
		
		List<int> indices;
//		int[] indices;
		
		/// <summary>
		/// An array of integers representing offsets within the Tweet text
		///	where the URL begins and ends. The first integer represents
		/// the location of the first character of the URL in the Tweet text.
		///	The second integer represents the location of the first non-URL
		///	character after the end of the URL.
		/// </summary>
		[JsonProperty("indices")]
		public List<int> Indices {
//		public int[] Indices {
			get { return indices; }
			set { indices = value; }
		}
		
		string rowUrl;
		
		/// <summary>
		/// Wrapped URL, corresponding to the value embedded directly into the raw
		///	Tweet text, and the values for the indices
		/// </summary>
		[JsonProperty("url")]
		public string RowUrl {
			get { return rowUrl; }
			set { rowUrl = value; }
		}
	}
	
	public class TwEntityUserMention
	{
		public TwEntityUserMention()
		{	
		}
		
		long id;
		
		/// <summary>
		/// ID of the mentioned user, as an integer.
		/// </summary>
		[JsonProperty("id")]
		public long Id {
			get { return id; }
			set { id = value; }
		}
		
		string idString;
		
		/// <summary>
		/// If of the mentioned user, as a string.
		/// </summary>
		[JsonProperty("id_str")]
		public string IdString {
			get { return idString; }
			set { idString = value; }
		}
		
		List<int> indices;
		
		/// <summary>
		/// An array of integers representing the offsets within the Tweet text
		///	where the user reference begins and ends. The first integer represents
		///	the location of the '@' character of the user mention. The second
		///	integer represents the location of the first non-screenname character
		///	following the user mention.
		/// </summary>
		[JsonProperty("indices")]
		public List<int> Indices {
			get { return indices; }
			set { indices = value; }
		}
		
		string userName;
		
		/// <summary>
		/// Display name of the referenced user.
		/// </summary>
		/// <example>
		/// "name":"Twitter API"
		/// </example>
		[JsonProperty("name")]
		public string UserName {
			get { return userName; }
			set { userName = value; }
		}
		
		string displayName;
		
		/// <summary>
		/// Screen name of the referenced user.
		/// </summary>
		[JsonProperty("screen_name")]
		public string DisplayName {
			get { return displayName; }
			set { displayName = value; }
		}
	}
}
